#pragma once 
#include <iostream>
#include <mutex>
#include <pthread.h>
#include "mutex.hpp"


using namespace MutexModule;
namespace ConddexModule
{
    class Conddex
    {
        public:
        Conddex()
        {}
        void wait(Mutex &mutex)
        {
            int n = pthread_cond_wait(&_cond,mutex.get());
        }
        void signal()
        {
            //唤醒一个线程
            int n = pthread_cond_signal(&_cond);
            (void)n;
        }
        void broadcast()
        {
            //唤醒所有线程
            int n = pthread_cond_broadcast(&_cond);
        }
        ~Conddex()
        {}
        private:
        pthread_cond_t _cond;
    };
}